import request from './http'

// 删除资料信息
function delInformation(id) {
    const url = `/api/data/delete`;
    return request.post(url,{id});
}
// 查询单个资料
function queryInformation(id){
    const params = new URLSearchParams();
    params.append("id", id);
    const url = `/api/data/findById`;
    return request.post(url,params);
}
// 获取全部资料  及查询
function getaddlist(pageNum,pageSize,fileType='',name='',startTime='',endTime=''){
    const url = `/api/data/getAll`;
    return request.post(url,{pageNum,pageSize,fileType,name,startTime,endTime});
}
// 获取全部产品
function getAllList(pageNum, pageSize,fileType='',name='',startTime='',endTime='') {
    const url = `/api/product/getAll`;
    return request.post(url,{pageNum,pageSize,fileType,name,startTime,endTime});
}
// 获取全部图集
function getAllGalList(pageNum, pageSize,fileType='',name='',startTime='',endTime='') {
    const url = `/api/atlas/findAll`;
    return request.post(url,{pageNum,pageSize,fileType,name,startTime,endTime});
}
// 查询单个产品
function queryProduct(id){
    const params = new URLSearchParams();
    params.append("id", id);
    const url = `/api/product/findById`;
    return request.post(url,params);
}
// 查询单个图册
function  queryGally(atlasId) {
    const url = `/api/atlas/findone/${atlasId}`;
    return request.get(url);
}
// 重命名 ---资料
function changeNameInfor (id,fileName){
    const url = `/api/data/addOrUpdate`;
    return request.post(url,{id,fileName});
}
// 重命名 ---产品
function changeNamePro (id,fileName){
    const url = `/api/product/addorUpdate`;
    return request.post(url,{id,fileName});
}
// 删除---产品
function delProduct(id){
    const url = `/api/product/delete`;
    return request.post(url,{id});

}
// 重命名 ---图册
function changeNameGal (id,fileName){
    const params = new URLSearchParams();
    params.append("id", id);
    params.append("fileName", fileName);
    const url = `/api/atlas/update`;
    return request.post(url,params);
}
// 删除  --- 图册
function delGallery (id) {
    const url = `/api/atlas/del/${id}`;
    return request.get(url);
}
// 上传文件
function uploadFile (connectionType,file){
    const formdata = new FormData();
    formdata.append('connectionType', connectionType);
    formdata.append('file', file);
    const url = `/api/minio/upload`;
    return request.post(url,formdata);
}
// 上传到库 ---资料
function updataInformation(categoryType,fileType,fileName,fileSize,fileUrl,uploadFileName) {
    const url = `/api/data/addOrUpdate`;
    return request.post(url,{categoryType,fileType,fileName,fileSize,fileUrl,uploadFileName});
}
// 上传到库---产品
function addProduct(categoryType,fileType,fileName,fileSize,uploadFileName,fileUrl,thumbnail){
    const url = `/api/product/addorUpdate`;
    return request.post(url,{categoryType,fileType,fileName,fileSize,uploadFileName,fileUrl,thumbnail});
}
// 上传到库---图册
function addGallery(categoryType,fileName,fileType,list,operator){
    const url = `/api/atlas/add`;
    return request.post(url,{categoryType,fileName,fileType,list,operator});
}
// 下载文件
function download(connectionType,fileName,id) {
    const url = `/api/minio/download?connectionType=${connectionType}&fileName=${fileName}&id=${id}`;
    return request.get(url,{responseType:'blob'});
}
// 获取文件路径
function accessPath() {
    const url = `/api/minio/getUrl`;
    return request.post(url,{});
}
// 获取层级关系
function getCategoryTree(){
    const url = `/api/information/getCategoryTree`;
    return request.post(url,{});
}
//数据展示-页面内容
function datuALl(pageSize,pageNum,categoryType){
    const url=`/api/information/getAll`;
    return request.post(url,{pageSize,pageNum,categoryType})
}
function selectALl(pageSize,pageNum,categoryType='',fileType='',name='',startTime='',endTime=''){
    const url=`/api/information/getAll`;
    return request.post(url,{pageSize,pageNum,categoryType,fileType,name,startTime,endTime})
}
//数据展示-删除
function delDatu(id,connectionId,connectionType){
    const url= `/api/information/delete`;
    return request.post(url,{id,connectionId,connectionType})
}
//shujuzhanshi-重命名
function chongDatu(id,connectionId,connectionType,fileName){
    const url= `/api/information/addOrUpdate`;
    return request.post(url,{id,connectionId,connectionType,fileName})
}

export {delInformation,queryInformation,updataInformation,queryProduct,getaddlist,getAllList,getAllGalList,
    queryGally,changeNameInfor,changeNamePro,changeNameGal,delGallery,delProduct,uploadFile ,addProduct,addGallery,
    download,accessPath,getCategoryTree,datuALl,delDatu,selectALl,chongDatu}



